<?php

class All extends TPage
{
	public $element_manager;
	public $count;
	
	public function onLoad($params)
	{
		parent::onLoad($params);
		
		$this->element_manager = $this->Application->Modules['requested_elements'];
		$page = $this->Application->Request['site'];
		$status = $this->Application->Request['status'];
		
		$this->count = $this->element_manager->countRequestedElementsByOwnerIdStatus(
													$this->User->getName(), $status);
		
		$page_params = $status === null ? array() : array('status' => $status);
		$this->site_manager->setData(	$this->Page->getPagePath(),
										$page_params,
										$page,
										$this->count,
										10);
			
		$this->RequestedElementList->DataSource = $this->element_manager->getRequestedElementsListByOwnerIdStatus(
													$this->User->getName(),
													$status,
													true,
													$this->site_manager->getOffset(),
													$this->site_manager->getElementsPerSite());
		$this->RequestedElementList->dataBind();
	}
	
	public function deleteButtonClicked($sender, $param)
	{
		$this->element_manager->deleteRequestedElement($param->CommandParameter);
		$this->Application->Response->reload();
	}
	
	public function showButtonClicked($sender, $param)
	{
		$this->Response->redirect(
			$this->Service->constructUrl('participant.requested_elements.Show',
										array('id' => $param->CommandParameter)));
	}
}

?>